package com.kurt.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * 操作日志表
 * 记录系统操作日志
 */
@Data
@Entity
@Table(name = "sys_oper_log")
public class SysOperLog {

    @Id
    @Column(name = "id", length = 36, nullable = false)
    private String id; // 日志ID

    @Column(name = "title", length = 100, nullable = false)
    private String title; // 操作模块

    @Column(name = "business_type")
    private Integer businessType; // 业务类型(0-其它,1-新增,2-修改,3-删除,4-授权,5-导出,6-导入,7-强退,8-生成代码,9-清空数据)

    @Column(name = "method", length = 255)
    private String method; // 请求方法

    @Column(name = "request_method", length = 10)
    private String requestMethod; // 请求方式(GET,POST,PUT,DELETE等)

    @Column(name = "operator_type")
    private Integer operatorType; // 操作类别(0-其它,1-后台用户,2-手机端用户)

    @Column(name = "oper_name", length = 50)
    private String operName; // 操作人员

    @Column(name = "dept_name", length = 50)
    private String deptName; // 部门名称

    @Column(name = "oper_url", length = 255)
    private String operUrl; // 请求URL

    @Column(name = "oper_ip", length = 128)
    private String operIp; // 主机地址

    @Column(name = "oper_location", length = 255)
    private String operLocation; // 操作地点

    @Column(name = "oper_param", columnDefinition = "TEXT")
    private String operParam; // 请求参数

    @Column(name = "json_result", columnDefinition = "TEXT")
    private String jsonResult; // 返回结果

    @Column(name = "status")
    private Integer status; // 操作状态(0-正常,1-异常)

    @Column(name = "error_msg", length = 2000)
    private String errorMsg; // 错误消息

    @Column(name = "oper_time")
    private LocalDateTime operTime; // 操作时间

    @Column(name = "cost_time")
    private Long costTime; // 消耗时间(毫秒)

    @Column(name = "tenant_id", length = 36)
    private String tenantId; // 租户ID

}
